<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
    
  </head>
  
  <body>
	<div>
	    <h1>UEditor</h1>
	    <form action = "publish/add" id="form" method="post"  target="id_iframe">
	    	标题：<input type = "text" name = "title"/><br/>
	    	摘要：<input type = "text" name = "summary"/><br/>
			作者：<input type = "text" name = "author"/><br/>
			学校ID：<input type = "text" name = "school_id"/><br/>
	    	<script id="editor" type="text/plain" style="width:1024px;height:500px;">
				测试一下UEditor
			</script>
			<input name="content" type="hidden" id="info">
			<input type="button" name="Submit" value=" 提交 " onClick="uptext();">
	    </form>
	    <iframe id="id_iframe" name="id_iframe" style="display:none;"></iframe>
	</div>
	
	<script type="text/javascript">

	    //实例化编辑器
	    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
	    var ue = UE.getEditor('editor');
	    
	    function uptext(){
			if (!ue.hasContents()){
				alert('请先填写内容!');
			}
			else{
				alert(ue.getContent());
				document.getElementById("info").value = ue.getContent();
				document.getElementById("form").submit();
			}
		}
	    
    </script>
  </body>
</html>
